import pygame

def load_image(file, colorkey = None): # file exist
    image = pygame.image.load(file).convert()
    if colorkey: image.set_colorkey(colorkey, pygame.RLEACCEL)
    return image

def load_frame(file, (sx, sy), colorkey = None):
    image = pygame.image.load(file).convert()
    if colorkey is not None: image.set_colorkey(colorkey, pygame.RLEACCEL)
    allrect = image.get_rect()
    width = (allrect.width) // sx
    height = (allrect.height) // sy
    frame = []
    for x in range(0, allrect.width, width):
        for y in range(0, allrect.height, height):
            sub = pygame.Surface((width, height))
            sub.blit(image, (0, 0), (x, y, width, height))
            if colorkey: sub.set_colorkey(colorkey, pygame.RLEACCEL)
            frame.append(sub)
    return tuple(frame)